/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package CareerService.Entitybeans;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Administrator
 */
@Entity
@Table(name = "towns")
@NamedQueries({@NamedQuery(name = "Towns.findAll", query = "SELECT t FROM Towns t"), @NamedQuery(name = "Towns.findByTownId", query = "SELECT t FROM Towns t WHERE t.townId = :townId"), @NamedQuery(name = "Towns.findByTownName", query = "SELECT t FROM Towns t WHERE t.townName = :townName")})
public class Towns implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "town_id")
    private Integer townId;
    @Basic(optional = false)
    @Column(name = "town_name")
    private String townName;
    @OneToMany(mappedBy = "town")
    private Collection<Jobs> jobsCollection;
    @OneToMany(mappedBy = "town")
    private Collection<Employer> employerCollection;

    public Towns() {
    }

    public Towns(Integer townId) {
        this.townId = townId;
    }

    public Towns(Integer townId, String townName) {
        this.townId = townId;
        this.townName = townName;
    }

    public Integer getTownId() {
        return townId;
    }

    public void setTownId(Integer townId) {
        this.townId = townId;
    }

    public String getTownName() {
        return townName;
    }

    public void setTownName(String townName) {
        this.townName = townName;
    }

    public Collection<Jobs> getJobsCollection() {
        return jobsCollection;
    }

    public void setJobsCollection(Collection<Jobs> jobsCollection) {
        this.jobsCollection = jobsCollection;
    }

    public Collection<Employer> getEmployerCollection() {
        return employerCollection;
    }

    public void setEmployerCollection(Collection<Employer> employerCollection) {
        this.employerCollection = employerCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (townId != null ? townId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Towns)) {
            return false;
        }
        Towns other = (Towns) object;
        if ((this.townId == null && other.townId != null) || (this.townId != null && !this.townId.equals(other.townId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "CareerService.Entitybeans.Towns[townId=" + townId + "]";
    }

}
